﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KL.Store.Core.Domain;
using TN.Data;

namespace KL.Store.Data
{
    public class dbOrder
    {
        #region Get

        public static Order Get(int UserId, int OrderId)
        {
            IList<Order> objectList = new List<Order>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Order_Get", objectList, new object[] { UserId, OrderId });

            return objectList.FirstOrDefault();
        }

        #endregion

        #region Cancel

        public static int Cancel(int UserId, int OrderId)
        {
            int i = (int)SqlHelper.ExecuteScalar(dbParameters.dsnStore, "SPR_ESTORE_Order_Cancel", new object[] { UserId, OrderId });

            return i;
        }

        #endregion

        #region GetList

        public static IList<Order> GetList(int UserId)
        {
            IList<Order> objectList = new List<Order>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Order_List", objectList, new object[] { UserId });

            return objectList;
        }

        #endregion

        #region GetDetail

        public static IList<OrderDetail> GetDetail(int UserId, int OrderId)
        {
            IList<OrderDetail> objectList = new List<OrderDetail>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Order_Detail", objectList, new object[] { UserId, OrderId });

            return objectList;
        }

        #endregion

        #region GetCargoRefList

        public static IList<OrderCargo> GetCargoRefList(int UserId, int OrderId)
        {
            IList<OrderCargo> objectList = new List<OrderCargo>();
            SqlHelper.FillList(dbParameters.dsnStore, "SPR_ESTORE_Order_Cargo", objectList, new object[] { UserId, OrderId });

            return objectList;
        }

        #endregion
    }
}
